import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/userAdd")
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("处理get请求");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("处理post请求");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        if(username.equals("aaa")&&password.equals("aaa")){
            System.out.println("转发");
            req.getRequestDispatcher("main.jsp").forward(req,resp);
        }
        if(username.equals("bbb")&&password.equals("bbb")){
            System.out.println("重定向");
            resp.sendRedirect("main.jsp");
        }
        if(username.equals("app")&&password.equals("1314")){
            System.out.println("重定向");
            resp.sendRedirect("main.jsp");
        }

    }
}
